package lc.排序算法;

import java.util.Arrays;

/**
 * @description:
 * @author: qian
 * @createDate: 2021/10/15
 */
public class selectSort {

    public static void main(String[] args) {
        int []a = {1,2,10,4,5,6,7,4};
        selection(a);
        System.out.println(Arrays.toString(a));
    }



    public static void selection(int[] a) {

        for (int i = 0; i < a.length; i++) {

            int max = i;
            for (int j = i + 1; j < a.length; j++) {

                if (a[max] < a[j]) {
                    max = j;
                }
            }
            int t = a[max];
            a[max] = a[i];
            a[i] = t;
        }
    }
}
